#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@version: 1.0
@author: xjl
@file: 代理设计模式.py
@time: 2022/10/6 19:08
"""

class ReceiveParcel:
    "接收包裹"

    def __init__(self, name):
        self.__name = name

    def getName(self):
        return self.__name

    def receive(self, parcelContent):
        pass

class TonyReception(ReceiveParcel):
    "Tony接收"

    def __init__(self, name, phoneNum):
        super().__init__(name)
        self.__phoneNum = phoneNum

    def getPhoneNum(self):
        return self.__phoneNum

    def receive(self, parcelContent):
        print("货物主人：" + self.getName() + "， 手机号：" + self.getPhoneNum())
        print("接收到一个包裹，包裹内容：" + parcelContent)

# 代理对象
class WendyReception(ReceiveParcel):
    "Wendy接收"

    def __init__(self, name, receiver):
        super().__init__(name)
        self.__receiver = receiver

    def receive(self, parcelContent):
        print("我是" + self.__receiver.getName() + "的朋友， 我来帮他代收快递！")
        if (self.__receiver is not None):
            self.__receiver.receive(parcelContent)
        print("代收人：" + self.getName())

def testProxy():
    tony = TonyReception("Tony", "18512345678")
    wendy = WendyReception("Wendy", tony)
    wendy.receive("雪地靴")

if __name__ == '__main__':
    pass
